package com.logicalthinking.socialmall.service.impl;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.PropertyCheckUtil;
import com.logicalthinking.socialmall.entity.ClientAuthenticateSelf;
import com.logicalthinking.socialmall.dao.ClientAuthenticateSelfMapper;
import com.logicalthinking.socialmall.service.ClientAuthenticateSelfServiceI;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户个人认证信息
 * @author chenLiJia
 * @since 2020-02-18 13:56:25
 **/
@Service
public class ClientAuthenticateSelfServiceImpl implements ClientAuthenticateSelfServiceI {


    @Resource
    private ClientAuthenticateSelfMapper clientAuthenticateSelfMapper;


    /**
     * 添加
     *
     * @param params      添加参数
     * @return com.github.chenlijia1111.utils.common.Result
     * @author chenLiJia
     * @since 2020-02-18 13:56:25
     **/
    @Override
    public Result add(ClientAuthenticateSelf params){
    
        int i = clientAuthenticateSelfMapper.insertSelective(params);
        return i > 0 ? Result.success("操作成功") : Result.failure("操作失败");
    }

    /**
     * 编辑
     *
     * @param params      编辑参数
     * @return com.github.chenlijia1111.utils.common.Result
     * @author chenLiJia
     * @since 2020-02-18 13:56:25
     **/
    @Override
    public Result update(ClientAuthenticateSelf params){
    
        int i = clientAuthenticateSelfMapper.updateByPrimaryKeySelective(params);
        return i > 0 ? Result.success("操作成功") : Result.failure("操作失败");
    }

    /**
     * 根据用户id查询认证信息
     * @param userId
     * @return
     */
    @Override
    public ClientAuthenticateSelf findByUserId(Integer userId) {
        return clientAuthenticateSelfMapper.selectByPrimaryKey(userId);
    }

    /**
     * 条件查询
     *
     * @param condition  
     * @return 
     * @author chenLiJia
     * @since 2020-02-18 13:56:25
     **/
    @Override
    public List<ClientAuthenticateSelf> listByCondition(ClientAuthenticateSelf condition){
    
        PropertyCheckUtil.transferObjectNotNull(condition, true);
        return clientAuthenticateSelfMapper.select(condition);
    }


}
